namespace NCT.MRS.DataAccessLayer.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using NCT.MRS.DataAccessLayer.Entities;

    internal sealed class Configuration : DbMigrationsConfiguration<NCT.MRS.DataAccessLayer.AppContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(NCT.MRS.DataAccessLayer.AppContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            context.AccessSections.AddOrUpdate(
                p => p.Name,
                new AccessSection
                {
                    Name = "Client",
                    AccessTypes = new System.Collections.Generic.List<AccessType>()
                    {
                        new AccessType { Name = "Add New Client",  Code = "add_client"},
                        new AccessType { Name = "Edit Client", Code = "edit_client"},
                        new AccessType { Name = "Delete Client", Code = "delete_client"}
                    }
                },
                new AccessSection
                {
                    Name = "Doctor",
                    AccessTypes = new System.Collections.Generic.List<AccessType>()
                    {
                        new AccessType { Name = "Add New Doctor", Code = "add_doctor"},
                        new AccessType { Name = "Edit Doctor", Code = "edit_doctor"},
                        new AccessType { Name = "Delete Doctor", Code = "delete_doctor"}
                    }
                }
            );
        }
    }
}
